home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / HYP / C-D / DartmouthXCMDs.cpt / Dartmouth XCMDs Vol 1&2 / card_7597.txt < prev    next >
Text File  |  1989-02-26  |  7KB  |  302 lines

  1. -- card: 7597 from stack: in
  2. -- bmap block id: 7696
  3. -- flags: 0000
  4. -- background id: 7022
  5. -- name: HyperTyper
  6. ----- HyperTalk script -----
  7. on openCard
  8.   global typerMenu
  9.   put NewMenu("HyperTyper","New","Open","Save","Save As‚Ķ", "(-","Print","QuickPrint","(-","Quit") into typerMenu
  10.   pass openCard
  11. end openCard
  12.  
  13. on closeCard
  14.   global typerMenu
  15.   hide card field 2
  16.   doNew
  17.   get deleteMenu(typerMenu)
  18.   put empty into typerMenu
  19.   if the freesize of this stack is not 0 then doMenu "Compact Stack"
  20.   pass closeCard
  21. end closeCard
  22.  
  23. on idle
  24.   global typerMenu
  25.   global lastTick
  26.   if (the ticks-lastTick)>30 then  --  gives better
  27.     -- performance than on every iteration
  28.     put the ticks into lastTick
  29.     if field 1 is empty then
  30.       EnableMenu typerMenu,3,"false"
  31.       EnableMenu typerMenu,4,"false"
  32.       EnableMenu typerMenu,6,"false"
  33.       EnableMenu typerMenu,7,"false"
  34.     else
  35.       EnableMenu typerMenu,3,"true"
  36.       EnableMenu typerMenu,4,"true"
  37.       EnableMenu typerMenu,6,"true"
  38.       EnableMenu typerMenu,7,"true"
  39.     end if
  40.   end if
  41.   pass idle
  42. end idle
  43.  
  44. on doError which
  45.   Answer which with "OK"
  46. end doError
  47.  
  48. on doNew
  49.   global windowDirty,typerFile
  50.   if field 1 is not empty then
  51.     if windowDirty is "true" then
  52.       answer "Save changes?" with "Cancel" or "No" or "Yes"
  53.       if it is "Cancel" then exit doNew
  54.       else if it is "Yes" then doSave
  55.     end if
  56.     put empty into field 1
  57.   end if
  58.   put "false" into windowDirty
  59.   put "Untitled" into card field "FileName"
  60.   set the name of field 1 to card field "FileName"
  61.   put empty into typerFile
  62. end doNew
  63.  
  64. on doOpen
  65.   global windowDirty,typerFile
  66.   if windowDirty is "true" then
  67.     if field 1 is not empty then
  68.       answer "Save changes?" with "Cancel" or "No" or "Yes"
  69.       if it is "Cancel" then exit to HyperCard
  70.       else if it is "Yes" then doSave
  71.     end if
  72.   end if
  73.   FileToField "field 1"
  74.   put the Result into theResult
  75.   if theResult is not empty then
  76.     if word 1 of theResult is "Error" then
  77.       doError theResult
  78.       exit doOpen
  79.     else if theResult is "Cancel" then exit doOpen
  80.     put theResult into typerFile
  81.     put LastPathComponent(typerFile) into card field "FileName"
  82.     set the name of field 1 to card field "FileName"
  83.     put "false" into windowDirty
  84.   end if
  85. end doOpen
  86.  
  87. on doSave
  88.   global windowDirty,typerFile
  89.   if the short name of field 1 is not "Untitled" then
  90.     FieldToFile "field 1",typerFile
  91.     if the Result is "Cancel" then
  92.       exit to HyperCard
  93.     else
  94.       put "false" into windowDirty
  95.       put the Result into theResult
  96.       if word 1 of theResult is "Error" then
  97.         doError theResult
  98.       end if
  99.     end if
  100.   else
  101.     doSaveAs
  102.   end if
  103. end doSave
  104.  
  105. on doSaveAs
  106.   global windowDirty,typerFile
  107.   FieldToFile "field 1"
  108.   put the Result into theResult
  109.   if word 1 of theResult is "Error" then
  110.     doError theResult
  111.     exit doSaveAs
  112.   end if
  113.   if theResult is "Cancel" then
  114.     exit to Hypercard
  115.   else
  116.     put theResult into typerFile
  117.     put LastPathComponent(typerFile) into card field "FileName"
  118.     put "false" into windowDirty
  119.   end if
  120. end doSaveAs
  121.  
  122. on doPrint
  123.   if field 1 is not empty then PrintField "field 1"
  124. end doPrint
  125.  
  126. on doQuickPrint
  127.   if field 1 is not empty then TextStream "field 1",8,10,4,4
  128. end doQuickPrint
  129.  
  130. on doQuit
  131.   visual effect dissolve
  132.   go to card 1
  133. end doQuit
  134.  
  135. on doMenu it
  136.   if it is "New" then
  137.     doNew
  138.   else if it is "Open" then
  139.     doOpen
  140.   else if it is "Save" then
  141.     doSave
  142.   else if it is "Save As‚Ķ" then
  143.     doSaveAs
  144.   else if it is "Print" then
  145.     doPrint
  146.   else if it is "QuickPrint" then
  147.     doQuickPrint
  148.   else if it is "Quit" then
  149.     doQuit
  150.   else pass doMenu
  151. end doMenu
  152.  
  153. on openField
  154.   global windowDirty,typerMenu
  155.   if the number of the target is 1 then
  156.     put "true" into windowDirty
  157.   end if
  158.   pass openField
  159. end openField
  160.  
  161.  
  162. -- part 1 (field)
  163. -- low flags: 01
  164. -- high flags: 0000
  165. -- rect: left=160 top=38 right=56 bottom=352
  166. -- title width / last selected line: 0
  167. -- icon id / first selected line: 0 / 0
  168. -- text alignment: 1
  169. -- font id: 0
  170. -- text size: 12
  171. -- style flags: 0
  172. -- line height: 16
  173. -- part name: FileName
  174.  
  175.  
  176. -- part 2 (button)
  177. -- low flags: 00
  178. -- high flags: 0000
  179. -- rect: left=477 top=54 right=63 bottom=494
  180. -- title width / last selected line: 0
  181. -- icon id / first selected line: 0 / 0
  182. -- text alignment: 1
  183. -- font id: 0
  184. -- text size: 12
  185. -- style flags: 0
  186. -- line height: 16
  187. -- part name: ScrollToTop
  188. ----- HyperTalk script -----
  189. on mouseUp
  190.   set scroll of field 1 to 0
  191. end mouseUp
  192.  
  193.  
  194.  
  195. -- part 4 (button)
  196. -- low flags: 00
  197. -- high flags: 2000
  198. -- rect: left=354 top=31 right=62 bottom=385
  199. -- title width / last selected line: 0
  200. -- icon id / first selected line: 32462 / 32462
  201. -- text alignment: 1
  202. -- font id: 0
  203. -- text size: 12
  204. -- style flags: 0
  205. -- line height: 16
  206. -- part name: 
  207. ----- HyperTalk script -----
  208. on mouseUp
  209.   set visible of card field 2 to not visible of card field 2
  210. end mouseUp
  211.  
  212.  
  213.  
  214. -- part 5 (button)
  215. -- low flags: 00
  216. -- high flags: 2000
  217. -- rect: left=393 top=28 right=59 bottom=432
  218. -- title width / last selected line: 0
  219. -- icon id / first selected line: 1007 / 1007
  220. -- text alignment: 1
  221. -- font id: 0
  222. -- text size: 12
  223. -- style flags: 0
  224. -- line height: 16
  225. -- part name: 
  226. ----- HyperTalk script -----
  227. on mouseUp
  228.   doMenu "Print"
  229. end mouseUp
  230.  
  231.  
  232.  
  233. -- part 6 (button)
  234. -- low flags: 00
  235. -- high flags: 0000
  236. -- rect: left=437 top=32 right=60 bottom=472
  237. -- title width / last selected line: 0
  238. -- icon id / first selected line: 20098 / 20098
  239. -- text alignment: 1
  240. -- font id: 0
  241. -- text size: 12
  242. -- style flags: 0
  243. -- line height: 16
  244. -- part name: 
  245. ----- HyperTalk script -----
  246. on mouseUp
  247.   go home
  248. end mouseUp
  249.  
  250.  
  251.  
  252. -- part 7 (field)
  253. -- low flags: 81
  254. -- high flags: 2002
  255. -- rect: left=22 top=62 right=326 bottom=494
  256. -- title width / last selected line: 0
  257. -- icon id / first selected line: 0 / 0
  258. -- text alignment: 0
  259. -- font id: 20
  260. -- text size: 12
  261. -- style flags: 0
  262. -- line height: 16
  263. -- part name: HyperTyper Help
  264. ----- HyperTalk script -----
  265. on mouseup
  266.   set the visible of me to false
  267. end mouseup
  268.  
  269.  
  270. -- part 8 (button)
  271. -- low flags: 00
  272. -- high flags: 2000
  273. -- rect: left=473 top=29 right=53 bottom=495
  274. -- title width / last selected line: 0
  275. -- icon id / first selected line: 1012 / 1012
  276. -- text alignment: 1
  277. -- font id: 0
  278. -- text size: 12
  279. -- style flags: 0
  280. -- line height: 16
  281. -- part name: Pop Card
  282. ----- HyperTalk script -----
  283. on mouseUp
  284.   visual effect dissolve
  285.   pop card
  286. end mouseUp
  287.  
  288.  
  289.  
  290. -- part contents for card part 1
  291. ----- text -----
  292. Untitled
  293.  
  294. -- part contents for card part 7
  295. ----- text -----
  296.  
  297. HyperTyper 1.1
  298. Kevin Calhoun
  299.  
  300. HyperTyper is a text editor built in HyperCard with the XCMD's from Dartmouth College and the menu XCMD's from Nine to Five Software.  It works much like the popular desk accessory text editors, reading and writing text files of less than 30K in size.  "Open," "Save," and "Save As..." in the HyperTyper menu act on files of type TEXT, the kind of file you get if you save a file as "Text Only" in most word processors.
  301.  
  302. You can set the font, font size, line height, alignment, and text style of the field as you normally do in HyperCard.  Choosing "Print" from the HyperTyper menu invokes the PrintField XCMD, which will print the text according to your settings.  Choosing "QuickPrint" invokes the TextStream XCMD, which will give you hardcopy in your printer's default monospaced font.